import axios from 'axios';

const rpcUrl = 'http://localhost:6800/jsonrpc'; // 默认RPC端口

const aria2Client = {
	call: async (method, params = []) => {
		const response = await axios.post(rpcUrl, {
			jsonrpc: '2.0',
			method: `aria2.${method}`,
			id: Date.now().toString(),
			params
		});
		return response.data.result;
	},
	addUri: (uri, options = {}) => {
		return aria2Client.call('addUri', [[uri], options]);
	},
	// 其他方法如remove, pause, tellStatus等
};

export default aria2Client;